package com.controller;

import com.pojo.Result;
import com.pojo.RisingPrices;
import com.pojo.RisingPricesHistory;
import com.pojo.TopUp;
import com.service.ConvenienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/Convenience")
@CrossOrigin
public class ConvenienceController {

    @Autowired
    private ConvenienceService convenienceService;


    /*这是更根据用户id，与分类来查询水电气费*/
    @RequestMapping("/Rising_Prices_find")
    public List<RisingPrices> Rising_Prices_find(int id){
        System.out.println("你好进入Rising_Prices_find里面了"+id);

        RisingPrices risingPrices = convenienceService.find(id);

        List<RisingPrices> list =new ArrayList<>();
        list.add(risingPrices);

        return list;
    }

    /*增加，水电气的*/
    @RequestMapping("/Rising_Prices_addChargeMoney")
    public void Rising_Prices_addChargeMoney(@RequestBody TopUp topUp){

        System.out.println("你好进入Rising_Prices_addChargeMoney里面了");
        convenienceService.Rising_Prices_addChargeMoney(topUp);
        System.out.println("你好Rising_Prices_addChargeMoney执行完了回来了");
    }

    /*减少，水电气的*/
    @RequestMapping("/Rising_Prices_descendChargeMoney")
    public void Rising_Prices_descendChargeMoney(int id,int category,int money){

        System.out.println("你好进入Rising_Prices_descendChargeMoney里面了");
        convenienceService.Rising_Prices_descendChargeMoney(id,category,money);
        System.out.println("你好Rising_Prices_descendChargeMoney执行完了回来了");

    }


    /*水电气充值历史查询*/
    @RequestMapping("/RisingPricesHistory")
    public List<RisingPricesHistory> RisingPricesHistoryFind(int id,int category){

        System.out.println("你好进入RisingPricesHistory里面了");
        List<RisingPricesHistory> list1 = convenienceService.RisingPricesHistoryFind(id,category);
        System.out.println("你好RisingPricesHistory执行完了回来了");

        return list1;
    }


    @RequestMapping(value = "/test", method = RequestMethod.POST)
    public void test(int id,int category){

        System.out.println("正在输出"+id+"...."+category);

    }


}